package com.annual.web.controller.system;

import com.annual.common.core.controller.BaseController;
import com.annual.common.core.domain.AjaxResult;
import com.annual.common.core.page.TableDataInfo;
import com.annual.system.dto.enterpriseBusiness.*;
import com.annual.system.dto.order.ReqOrderIdDto;
import com.annual.system.dto.order.ReqOrderPayListDto;
import com.annual.system.dto.order.ResOrderPayListDto;
import com.annual.system.dto.order.ResOrderRefundListDto;
import com.annual.system.service.IEnterpriseBusinessService;
import com.annual.system.service.IOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 参数配置 信息操作处理
 * 
 * @author annualReview
 */
@Api(tags="年审送报")
@RestController
@RequestMapping("/system/enterprise/business")
public class EnterpriseBusinessController extends BaseController {

    @Autowired
    private IOrderService orderService;
    @Autowired
    private IEnterpriseBusinessService enterpriseBusinessService;

    @ApiOperation(value = "列表",notes = "ywb")
    @GetMapping("/list")
    public TableDataInfo list(ReqEnterpriseBusinessListDto req){
        startPage();
        List<ResEnterpriseBusinessListDto> list = enterpriseBusinessService.pcList(req);
        return getDataTable(list);
    }

    @ApiOperation(value = "获取详情",notes = "ywb")
    @GetMapping("/getInfo/{enterpriseBusinessId}")
    public AjaxResult<ResEnterpriseBusinessInfoDto> getInfo(@PathVariable Long enterpriseBusinessId){
        ResEnterpriseBusinessInfoDto info = enterpriseBusinessService.getInfo(enterpriseBusinessId);
        return success(info);
    }

    @ApiOperation(value = "编辑",notes = "ywb")
    @PostMapping("/edit")
    public AjaxResult<ResEnterpriseBusinessInfoDto> edit(@RequestBody ResEnterpriseBusinessUpdateDto dto){
        enterpriseBusinessService.edit(dto);
        return success("编辑成功");
    }

    @ApiOperation(value = "支付订单列表",notes = "ywb")
    @GetMapping("/pay/list")
    public TableDataInfo payList(ReqOrderPayListDto req){
        startPage();
        List<ResOrderPayListDto> list = orderService.payList(req);
        return getDataTable(list);
    }


    @ApiOperation(value = "退款订单列表",notes = "ywb")
    @GetMapping("/refund/list")
    public TableDataInfo refundList(ReqOrderPayListDto req){
        startPage();
        List<ResOrderRefundListDto> list = orderService.refundList(req);
        return getDataTable(list);
    }


    @ApiOperation(value = "退款",notes = "ywb")
    @PostMapping("/refund")
    public AjaxResult<ResEnterpriseBusinessInfoDto> refund(@RequestBody ReqOrderIdDto dto){
        orderService.refund(dto.getOrderId());
        return success("退款成功");
    }


}
